<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script type="text/javascript">
    function page(n, s) {
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchFormRegist1").submit();
        return false;
    }
    $(function () {
        $("#regist").on('click', function () {
            var selctedClinicSchedules = $("#clinicIndexTable input[name=clinicScheduleId]:checked");
            if (selctedClinicSchedules.length <= 0) {
                toastr.error("请先选择出诊安排！");
                return;
            }
            var clinicScheduleIds = '';
            selctedClinicSchedules.each(function () {
                clinicScheduleIds = clinicScheduleIds + $(this).val() + ",";
            })
            clinicScheduleIds = clinicScheduleIds.substring(0, clinicScheduleIds.length - 1);
            var startDate = $("#startDate").val();
            var endDate = $("#endDate").val();
            if (startDate == null || startDate == "") {
                toastr.error("请选择开始日期！");
                return;
            }
            if (endDate == null || endDate == "") {
                toastr.error("请选择结束日期！");
                return;
            }
            $("#startTime").val(startDate);
            $("#endTime").val(endDate);
            $("#clinicScheduleIds").val(clinicScheduleIds);
            $("#searchFormRegist").submit();
        })
        /**
         * 删除号表按钮操作
         */
        $("#delBtn").on('click', function () {
            var clinicForRegistIds = '';
            var selectedData = $("input[name=clinicForRegistId]:checked");
            if (selectedData.length <= 0) {
                toastr.error("请选择要删除的号表数据");
                return;
            }
            selectedData.each(function () {
                clinicForRegistIds = clinicForRegistIds + $(this).val() + ",";
            })
            clinicForRegistIds = clinicForRegistIds.substring(0, clinicForRegistIds.length - 1);
            $("#clinicForRegistIds").val(clinicForRegistIds);
            $("#deleteFormRegist").submit();
        })
    })
</script>
<div class="wrapper no-p" style="background-color: white;bottom: 50px;">
    <div class="table-responsive no-border">
        <div class="datatable-top" style="padding-top: 5px;padding-left:10px;">
            <div class="pull-left">
                <form:form hidden="hidden" id="deleteFormRegist" modelAttribute="clinicForRegist"
                           onsubmit="return formSaveLoad('rigthCenterDiv','deleteFormRegist','${ctx}/reg/clinicForRegist/delete','${ctx}/reg/clinicForRegist/registList');"
                           method="post" class="form-inline">
                    <input type="hidden" id="clinicForRegistIds" name="clinicForRegistIds"/>
                </form:form>
                <form:form id="searchFormRegist" modelAttribute="clinicForRegist"
                           onsubmit="return formSaveLoad('rigthCenterDiv','searchFormRegist','${ctx}/reg/clinicForRegist/regist','${ctx}/reg/clinicForRegist/registList');"
                           method="post" class="form-inline">
                    <input type="hidden" id="startTime" name="startTime"/>
                    <input type="hidden" id="endTime" name="endTime"/>
                    <input type="hidden" id="clinicScheduleIds" name="clinicSchedulesIds"/>
                    号表生成日期：
                    <input id="startDate" class="form-control Wdate" type="text" value="${startDate}"
                           onFocus="var endDate=$dp.$('endDate');WdatePicker({onpicked:function(){endDate.focus();},minDate:'%y-%M-{%d}',maxDate:'#F{$dp.$D(\'endDate\')}'})"
                           readonly="readonly"/>
                    <label>至：</label>
                    <input id="endDate" class="form-control Wdate" type="text" value="${endDate}" readonly="readonly"
                           onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startDate\')}'})"/>
                    <input id="regist" class="btn btn-primary" type="button" value="生成"/>
                    <input style="background-color: red" id="delBtn" class="btn btn-primary" type="button" value="删除"/>
                </form:form>
                <form:form hidden="hidden" id="searchFormRegist1" modelAttribute="clinicForRegist"
                           onsubmit="return loadDivForm('rigthCenterDiv','searchFormRegist1','${ctx}/reg/clinicForRegist/registList');"
                           method="post" class="form-inline">
                    <input id="pageNo" name="pageNo" type="hidden" value="${clinicForRegistPage.pageNo}"/>
                    <input id="pageSize" name="pageSize" type="hidden" value="${clinicForRegistPage.pageSize}"/>
                </form:form>
            </div>
        </div>
        <table id="clinicForRegistTable" checkbox="true" class="table table-bordered mg-t datatable">
            <thead>
            <tr>
                <th style="width: 5%"><input type=checkbox id="clinicForRegistId"></th>
                <th>号别名称</th>
                <th>出诊日期</th>
                <th>出诊时间</th>
                <th>当前号</th>
                <th>限号数</th>
                <th>限预约号数</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${clinicForRegistPage.list}" var="clinicForRegist">
            <tr style="text-align: center;">
                <td style="width: 5%">
                    <input type="checkbox" value="${clinicForRegist.id}" name="clinicForRegistId">
                </td>
                <td> ${clinicForRegist.clinicIndexName}</td>
                <td><fmt:formatDate value="${clinicForRegist.clinicDate}" pattern="yyyy-MM-dd"/></td>
                <td> ${clinicForRegist.timeDescTrans}</td>
                <td> ${clinicForRegist.currentNum}</td>
                <td> ${clinicForRegist.limitNum}</td>
                <td> ${clinicForRegist.limitPreNum}</td>
            </tr>
            </c:forEach>
        </table>
        <div class="pagination">${clinicForRegistPage}</div>
    </div>
</div>

